//
//  AlertViewNoBtnViewController.m
//  UITest
//
//  Created by wp w on 12-6-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "AlertViewNoBtnViewController.h"
@implementation AlertViewNoBtnViewController


NSTimer *timer;
- (void)hideAlert:(NSTimer *)sender
{
	UIAlertView *alert = [sender userInfo];
	
	[alert dismissWithClickedButtonIndex:0 animated:YES];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)btnClicked {
    //创建一个5秒后自动消失的，且可点击的对话框
	UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"Configuring PreferencesnPlease Wait..." 
													  message:nil
													 delegate:self 
											cancelButtonTitle:nil 
											otherButtonTitles:nil];
	
    //对话框显示
	[myAlert show];
	
    //设置一个定时器，5秒后执行
	//create a timer to hide the alert automatically in 5 seconds
	timer = [[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(hideAlert:) userInfo:myAlert repeats:NO] retain];
	
	[myAlert release];
}

- (IBAction)btn1Clicked {
    //创建一个5秒后自动消失的，且可点击的对话框
	UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring PreferencesnPlease Wait..." 
													  message:nil
													 delegate:self 
											cancelButtonTitle:nil 
											otherButtonTitles:nil];
	
    //对话框显示
	[myAlert show];
	
    //设置一个定时器，5秒后执行
	//create a timer to hide the alert automatically in 5 seconds
	timer = [[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(hideAlert:) userInfo:myAlert repeats:NO] retain];
	
	[myAlert release];
}

- (IBAction)btn2Clicked {
    //创建一个5秒后自动消失的，且可点击的对话框
	UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"Configuring PreferencesnPlease Wait..." 
													  message:nil
													 delegate:self 
											cancelButtonTitle:nil 
											otherButtonTitles:nil];
    //对话框显示
	[myAlert show];
    
    
    //在对话框中添加一个等待标志
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    // Adjust the indicator so it is up a few pixels from the bottom of the alert
    indicator.center = CGPointMake(myAlert.bounds.size.width / 2, myAlert.bounds.size.height - 50);
    [indicator startAnimating];
    [myAlert addSubview:indicator];
    [indicator release];
	
	
    //设置一个定时器，5秒后执行
	//create a timer to hide the alert automatically in 5 seconds
	timer = [[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(hideAlert:) userInfo:myAlert repeats:NO] retain];
	
	[myAlert release];
}

- (void)dealloc {
    [timer invalidate];
	[timer release];
	timer = nil;
    [super dealloc];
}
@end
